package gui.wizard;

import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;

public class CheckDataPanel extends JPanel {

    // Final Fields
    final Color NOERRORCOLOR = new Color(34, 139, 34);
    final Color ERRORCOLOR = new Color(153, 31, 18);
    // Private Fields
    private JLabel anotherBlankSpace;
    private JLabel blankSpace;
    private JLabel lblusernameTest;
    private JLabel lblVillageNameTest;
    private JPanel jPanel1;
    private JLabel progressDescription;
    private JProgressBar progressSent;
    private JLabel welcomeTitle;
    private JLabel yetAnotherBlankSpace1;
    private JPanel contentPanel;
    private JLabel textLabel;
    private JPanel titlePanel;

    public CheckDataPanel() {

        super();

        contentPanel = getContentPanel();

        titlePanel = new javax.swing.JPanel();
        textLabel = new javax.swing.JLabel();


        setLayout(new java.awt.BorderLayout());

        titlePanel.setLayout(new java.awt.BorderLayout());
        titlePanel.setBackground(Color.gray);

        textLabel.setBackground(Color.gray);
        textLabel.setFont(new Font("MS Sans Serif", Font.BOLD, 14));
        textLabel.setText("Check Game Data");
        textLabel.setBorder(new EmptyBorder(new Insets(10, 10, 10, 10)));
        textLabel.setOpaque(true);

        titlePanel.add(textLabel, BorderLayout.CENTER);

        add(titlePanel, BorderLayout.NORTH);
        JPanel secondaryPanel = new JPanel();
        secondaryPanel.add(contentPanel, BorderLayout.NORTH);
        add(secondaryPanel, BorderLayout.WEST);

    }

    public void setProgressText(String s) {
        progressDescription.setText(s);
    }

    public void setProgressValue(int i) {
        progressSent.setValue(i);
    }

    public void setUsertest(boolean passed) {

        if (passed) {
            getLblusernameTest().setText("Username doesn't exist.");
            getLblusernameTest().setForeground(NOERRORCOLOR);
        } else {
            getLblusernameTest().setText("Username already exists!");
            getLblusernameTest().setForeground(ERRORCOLOR);
        }
    }

    public void setVillageTest(boolean passes) {

        if (passes) {
            getLblVillageNameTest().setText("Village Name doesn't exist.");
            getLblVillageNameTest().setForeground(NOERRORCOLOR);
        } else {
            getLblVillageNameTest().setText("Village Name already exists!");
            getLblVillageNameTest().setForeground(ERRORCOLOR);
        }
    }

    private JPanel getContentPanel() {

        JPanel contentPanel1 = new JPanel();

        welcomeTitle = new JLabel();
        jPanel1 = new JPanel();
        blankSpace = new JLabel();
        progressSent = new JProgressBar();
        progressDescription = new JLabel();
        anotherBlankSpace = new JLabel();
        yetAnotherBlankSpace1 = new JLabel();
        setLblusernameTest(new JLabel());
        setLblVillageNameTest(new JLabel());

        contentPanel1.setLayout(new java.awt.BorderLayout());
        contentPanel1.setBorder(new EmptyBorder(15, 0, 0, 0));

        welcomeTitle.setText("Checking if username or Village Name already exists:");
        contentPanel1.add(welcomeTitle, java.awt.BorderLayout.NORTH);

        jPanel1.setLayout(new java.awt.GridLayout(0, 1));

        jPanel1.add(blankSpace);

        progressSent.setStringPainted(true);
        jPanel1.add(progressSent);

        progressDescription.setFont(new java.awt.Font("MS Sans Serif", 1, 11));
        progressDescription.setText("making username");
        jPanel1.add(progressDescription);

        jPanel1.add(anotherBlankSpace);

        jPanel1.add(yetAnotherBlankSpace1);

        contentPanel1.add(jPanel1, java.awt.BorderLayout.CENTER);

        getLblusernameTest().setText("");
        getLblVillageNameTest().setText("");

        JPanel testLabels = new JPanel(new GridLayout(0, 1, 10, 10));
        testLabels.add(getLblusernameTest());
        testLabels.add(getLblVillageNameTest());

        contentPanel1.add(testLabels, java.awt.BorderLayout.SOUTH);

        return contentPanel1;
    }


    public JLabel getLblusernameTest() {
        return lblusernameTest;
    }

    public void setLblusernameTest(JLabel lblusernameTest) {
        this.lblusernameTest = lblusernameTest;
    }

    public JLabel getLblVillageNameTest() {
        return lblVillageNameTest;
    }

    public void setLblVillageNameTest(JLabel lblVillageNameTest) {
        this.lblVillageNameTest = lblVillageNameTest;
    }
}
